package com.boot.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component //让Spring识别 并且注入成bean
@Aspect
public class SysLog {
    public static Logger logger = LoggerFactory.getLogger(SysLog.class);

    //定义规则
    @Pointcut(value = "execution(* com.boot.service.*.list(..))")
    public void pointCut() {
    }

    //使用切入点引用
    @Around("SysLog.pointCut()")
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {

        logger.debug("开始方法:{}",proceedingJoinPoint.getSignature().getName());

        Object ret = proceedingJoinPoint.proceed();
        logger.debug("结束方法:{}",proceedingJoinPoint.getSignature().getDeclaringType());

        return ret;
    }

}
